import { getFormatterPrice } from '@const/filter'
const getRate = val => {
  if (isNaN(val) || val === void 0) {
    return
  }
  return Number(val) * 100 + '%'
}
export const invoiceHeaderColumns = [
  { prop: 'part', label: '', 'min-width': 40 },
  { prop: 'baseKey', label: '', 'min-width': 108 },
  { prop: 'baseValue', label: '', 'min-width': 328, 'show-overflow-tooltip': false },
  { prop: 'areaKey', label: '', 'min-width': 61 },
  { prop: 'areaValue', label: '', 'min-width': 229 }
]
export const invoiceFooterColumns = [
  { prop: 'part', label: '', 'min-width': 39 },
  { prop: 'baseKey', label: '', 'min-width': 115 },
  { prop: 'baseValue', label: '', 'min-width': 229, 'show-overflow-tooltip': false },
  { prop: 'areaKey', label: '', 'min-width': 61 },
  { prop: 'areaValue', label: '', 'min-width': 319 }
]
export const invoiceTotalColumns = [
  { prop: 'bigKey', label: '', 'min-width': 154 },
  { prop: 'bigValue', label: '', 'min-width': 229, 'show-overflow-tooltip': false },
  { prop: 'smallKey', label: '', 'min-width': 61 },
  { prop: 'smallValue', label: '', 'min-width': 319 }
]
export const invoiceDetailColumns = [
  { prop: 'first', label: '', 'min-width': 17 },
  { type: 'index', label: '行号', width: '60px', 'show-overflow-tooltip': true },
  { prop: 'name', label: '货物或应税劳务服务名称', 'min-width': 199, 'show-overflow-tooltip': true },
  { prop: 'spec', label: '规格型号', 'min-width': 79, 'show-overflow-tooltip': true },
  { prop: 'unit', label: '单位', 'min-width': 47, 'show-overflow-tooltip': true },
  { prop: 'num', label: '数量', 'min-width': 96, 'show-overflow-tooltip': true },
  {
    prop: 'price',
    label: '单价',
    width: 150,
    'show-overflow-tooltip': true,
    formatter: row => getFormatterPrice(row.price)
  },
  {
    prop: 'amount',
    label: '金额',
    'min-width': 80,
    'show-overflow-tooltip': true,
    formatter: row => getFormatterPrice(row.amount)
  },
  {
    prop: 'taxRate',
    label: '税率',
    'min-width': 65,
    'show-overflow-tooltip': true,
    formatter: row => getRate(row.taxRate)
  },
  { prop: 'taxAmount', label: '税额', 'min-width': 63, 'show-overflow-tooltip': true },
  { prop: 'end', label: '', 'min-width': 17 }
]

// 发票明细
export const invoiceColumns = [
  { prop: 'invoiceNo', label: '发票号码', width: 110, 'show-overflow-tooltip': true },
  { prop: 'invoiceKindName', label: '发票类型', width: 110, 'show-overflow-tooltip': true },
  { prop: 'invoiceCode', label: '发票代码', width: 110, 'show-overflow-tooltip': true },
  { prop: 'invoiceDate', label: '开票日期', width: 110, 'show-overflow-tooltip': true },
  { prop: 'totalPriceTax', label: '价税合计', width: 110, 'show-overflow-tooltip': true },
  // { prop: 'invoiceNo', label: '税率', width: 110, 'show-overflow-tooltip': true },
  { prop: 'totalTax', label: '税额', width: 110, 'show-overflow-tooltip': true },
  { prop: 'amountNoTax', label: '发票金额', width: 110, 'show-overflow-tooltip': true },
  { prop: 'checkCode', label: '检验码', width: 110, 'show-overflow-tooltip': true },
  { prop: 'saleCompany', label: '销售方', width: 110, 'show-overflow-tooltip': true },
  { prop: 'saleRegistrationCode', label: '销售方纳税人识别号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'buyCompany', label: '采购方', width: 110, 'show-overflow-tooltip': true },
  { prop: 'buyRegistrationCode', label: '采购方纳税人识别号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'remark', label: '备注', width: 110, 'show-overflow-tooltip': true }
]
// 发票明细
export const infoFootersColumns = [
  { prop: 'payee', label: '收款人' },
  { prop: 'reviewer', label: '复核人' },
  { prop: 'drawer', label: '开票人' },
  { prop: 'saleCompany', label: '销货单位' }
]
